// 计算BMI
function calculateBMI(weight, height) {
  const heightInMeters = height / 100;
  return weight / (heightInMeters * heightInMeters);
}

// 计算基础代谢率(BMR)
function calculateBMR(weight, height, age, gender) {
  if (gender === 'male') {
    return 66 + (13.7 * weight) + (5 * height) - (6.8 * age);
  } else {
    return 655 + (9.6 * weight) + (1.8 * height) - (4.7 * age);
  }
}

// 获取体重建议类型
function getRecommendationType(bmi) {
  if (bmi < 18.5) {
    return '偏瘦';
  } else if (bmi >= 18.5 && bmi < 24) {
    return '正常';
  } else if (bmi >= 24 && bmi < 28) {
    return '超重';
  } else {
    return '肥胖';
  }
}

module.exports = {
  calculateBMI,
  calculateBMR,
  getRecommendationType
}; 